﻿/* ***********************************************************************************************
 * Oak_Steering
 * Version: 1.0
 * Author:  BRyan Solero  
 * Email:  arindil@gmail.com
 * Copyright 2012.  All Rights Reserved.
 * 
 * ************************************************************************************************/
using System;

using Microsoft.Xna.Framework;

namespace OakEngine.AI.Steering
{
   public class Oak_Steering
   {
       private Vector2 m_vecForwardVector;
       public Vector2 ForwardVector { get { return m_vecForwardVector; } set { m_vecForwardVector = value; } }

       private float m_fRotation;
       public float Rotation { get { return m_fRotation; } set { m_fRotation = value; } }

       public Oak_Steering()
       {
           m_fRotation =0.0f;
       }

       public Oak_Steering(Vector2 fwd)
       {
           m_vecForwardVector = fwd;
           m_fRotation = 0.0f;
       }

       public Oak_Steering(Vector2 fwd, float angle)
       {
           m_vecForwardVector = fwd;
           m_fRotation = angle;
       }

       public Oak_Steering(float x, float y, float angle)
       {
           m_vecForwardVector = new Vector2(x,y);
           m_fRotation = angle;
       }

       public void ZeroOut()
       {
           m_fRotation = 0;
           m_vecForwardVector = Vector2.Zero;
       }


       public static bool operator !=(Oak_Steering lhs, Oak_Steering rhs)
       {
           return (lhs.m_vecForwardVector != rhs.m_vecForwardVector || lhs.m_fRotation != rhs.m_fRotation);

       }

       public static bool operator ==(Oak_Steering lhs, Oak_Steering rhs)
       {
           return (lhs.m_vecForwardVector == rhs.m_vecForwardVector && lhs.m_fRotation == rhs.m_fRotation);

       }

       float ForwardVectorSquareMagnitude()
       {
           return (m_vecForwardVector.X*m_vecForwardVector.X + m_vecForwardVector.Y*m_vecForwardVector.Y);
       }

       public float SquareMagnitude()
       {
           return ForwardVectorSquareMagnitude() + m_fRotation * m_fRotation;
       }

       public float Magnitude()
       {
           return (float) Math.Sqrt(SquareMagnitude());
       }
   }
}
